import { CopyInfoPanelBase } from "../CopyInfoPanelBase";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ImagesConst } from "../../../resource/ImagesConst";
import { MagicTowerAwardItems } from "../magicTower/MagicTowerAwardItems";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
import { CopyConfig } from "../../../resource/CopyConfig";
import { MapFileUtil } from "../../../scene/map/MapFileUtil";
import { ItemData } from "../../../resource/info/ItemData";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class SeventyCopyInfoPanel
    
    export  class SeventyCopyInfoPanel extends CopyInfoPanelBase
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._condition = ObjCreate.createGTextField(Language.getString(60435), _left, 0, 235, 20, _bodySp, new GTextFormat(FontUtil.songtiName, 12, 16776960));
            this._condition.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._condition.mouseEnabled = false;
            this._conditionText = ObjCreate.createGTextField("", _left + 30, 0, 220, 100, _bodySp, new GTextFormat(FontUtil.songtiName, 12, GlobalStyle.color1Uint, null, null, null, null, null, null, null, null, null, 5));
            this._conditionText.multiline = true;
            this._conditionText.wordWrap = true;
            this._conditionText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._conditionText.mouseEnabled = false;
            this._leftTime = ObjCreate.createGTextField(Language.getString(60410), _left, 25, 235, 20, _bodySp, new GTextFormat(FontUtil.songtiName, 13.3, 16776960, true));
            this._leftTime.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._leftTime.mouseEnabled = false;
            this._line = ObjCreate.createBg(_left, 0, 250, 2, _bodySp, ImagesConst.SplitLine);
            this._reward = ObjCreate.createGTextField(Language.getString(60434), _left, 0, 235, 20, _bodySp, new GTextFormat(FontUtil.songtiName, 12, 16776960));
            this._reward.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._reward.mouseEnabled = false;
            this._rewardItems = new MagicTowerAwardItems();
            this._rewardItems.x = _left + 20;
            _bodySp.addChild(this._rewardItems);
            return;
        }

        public updateTimes(arg1: int): void
        {
            if (arg1 != -1) 
            {
                if (!this._timer) 
                {
                    this._timer = new SecTimer();
                    this._timer.addListener(TimerType.ENTERFRAME, this.onSectimer);
                }
                this._timer.reset();
                this._timer.repeatCount = arg1;
                this._timer.start();
            }
            else if (this._timer && this._timer.running) 
            {
                this._timer.stop();
                this._leftTime.htmlText = Language.getString(60433) + Language.getString(60073);
            }
            return;
        }

        public /* override */ updateInfos(arg1): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc1=CopyConfig.instance.getSeventyCopyConfig(MapFileUtil.mapID);
            if (loc1) 
            {
                this.title = loc1.spaceName;
                this._conditionText.htmlText = loc1.describe;
                if (loc1.dropItem) 
                {
                    loc2 = loc1.dropItem.split("#");
                    loc4 = [];
                    var loc5=0;
                    var loc6=loc2;
                    for(loc3 of loc6) 
                    {
                        loc4.push(new ItemData(parseInt(loc3)));
                    }
                    this._rewardItems.setAwardItems(loc4, 5);
                }
            }
            this.resize();
            return;
        }

        /* internal  */onSectimer(arg1: SecTimer): void
        {
            this._leftTime.htmlText = this.getRemainTimeText(arg1.repeatCount);
            this.resize();
            return;
        }

        /* internal  */getRemainTimeText(arg1: int): string
        {
            var loc1=Language.getString(60433);
            if (arg1 > 99) 
            {
                loc1 = loc1 + HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(arg1, true), "#FE7E00");
            }
            else 
            {
                loc1 = loc1 + ("<font face=\'" + FontUtil.stXingkaiName + "\' size=\'50\'>" + HTMLUtil.addColor(arg1 + "\t", "#FFFF00") + "</font>");
                loc1 = loc1 + ("<font face=\'" + FontUtil.stXingkaiName + "\' size=\'18\'>" + HTMLUtil.addColor(Language.getString(60364), "#FFFF00") + "</font>");
            }
            return loc1;
        }

        /* internal  */resize(): void
        {
            var loc1=0;
            loc1 = 5;
            this._condition.y = loc1;
            loc1 = loc1 + this._condition.height;
            this._conditionText.y = loc1;
            loc1 = loc1 + (this._conditionText.height + 5);
            this._leftTime.y = loc1;
            loc1 = loc1 + (this._leftTime.height + 5);
            this._line.y = loc1;
            loc1 = loc1 + 7;
            this._reward.y = loc1;
            loc1 = loc1 + (this._reward.height + 7);
            this._rewardItems.y = loc1;
            loc1 = loc1 + 42;
            _bg.height = loc1 + 10;
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            if (this._timer) 
            {
                this._timer.stop();
                this._timer.dispose();
                this._timer = null;
            }
            return;
        }

        /* internal */ /* var */_condition: GTextFiled;

        /* internal */ /* var */_conditionText: GTextFiled;

        /* internal */ /* var */_leftTime: GTextFiled;

        /* internal */ /* var */_line: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_reward: GTextFiled;

        /* internal */ /* var */_rewardItems: MagicTowerAwardItems;

        /* internal */ /* var */_timer: SecTimer;
    }
